<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title>javascript study</title>
    </head>
    <body>
       
        <script >
        function myFunction() {
            var message, x;
            message = document.getElementById("message");
            message.innerHTML = "";
            x = document.getElementById("demo").value;
            try { 
                if(x == "")  throw "值为空";
                if(isNaN(x)) throw "不是数字";
                x = Number(x);
                if(x < 5)    throw "太小";
                if(x > 10)   throw "太大";
            }
            catch(err) {
                message.innerHTML = "错误: " + err;
            }
        }
        </script>
    </body>
</html>